//
//  GYDistributionInfomationViewController.m
//  GoodLuck
//
//  Created by 郭为勇 on 2018/3/3.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYDistributionInfomationViewController.h"
#import "GYSearchViewController.h"
#import "GYBasePopoverViewController.h"
#import "PopoverAnimation.h"
#import "GYSystemMessageViewController.h"
@interface GYDistributionInfomationViewController ()

/** 动画代理 */
@property (nonatomic, strong) PopoverAnimation *animationDelegate;
@property (weak, nonatomic) IBOutlet UILabel *invite_codeLable;
@property (weak, nonatomic) IBOutlet UILabel *vipVite_codeLable;
@property (weak, nonatomic) IBOutlet UILabel *menber_countLable;
@property (weak, nonatomic) IBOutlet UILabel *orderPointLable;
@property (weak, nonatomic) IBOutlet UILabel *vipMenber_countLable;
@property (weak, nonatomic) IBOutlet UILabel *pointsLable;
@property (weak, nonatomic) IBOutlet UILabel *cityPointsLable;

@end

@implementation GYDistributionInfomationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //初始化
    [self setupUI];
}

- (void)setupUI {
    self.navigationItem.title = @"分销信息";
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"more_b" tagret:self action:@selector(rightButClick) button:nil];
    
    //赋值
    NSLog(@"====%@ =====%@",self.userInfo.inviter_code,self.userInfo.vip_inviter_code);
    self.invite_codeLable.text = [NSString stringWithFormat:@"我的会员邀请码:%@",self.userInfo.inviter_code];
    self.vipVite_codeLable.text = [NSString stringWithFormat:@"我的VIP邀请码:%@",self.userInfo.vip_inviter_code];
    self.menber_countLable.text = [NSString stringWithFormat:@"已经成功邀请会员:%d人",self.userInfo.member_count];
    self.orderPointLable.text = [NSString stringWithFormat:@"通过线下会员消费返利得到的积分:%d积分",self.userInfo.getorderpoints];
    self.vipMenber_countLable.text = [NSString stringWithFormat:@"已成功邀请的VIP会员:%d人",self.userInfo.vipmember_count];
    self.pointsLable.text = [NSString stringWithFormat:@"获取平台奖励:%d积分",self.userInfo.getpoints];
    self.cityPointsLable.text = [NSString stringWithFormat:@"获取管辖区店铺销售奖励%d积分",self.userInfo.getcitypoints];
}

- (void)rightButClick {
    GYBasePopoverViewController *basePopoverVC = [[GYBasePopoverViewController alloc] initWithNibName:@"GYBasePopoverViewController" bundle:nil];
    __weak typeof(self) weakSelf = self;
    basePopoverVC.popoverViewSelectIndexCallBack = ^(NSInteger index) {
        switch (index) {
            case 0:
            {
                weakSelf.tabBarController.selectedIndex = 0;
                [weakSelf.tabBarController.tabBar setHidden:NO];
            }
                break;
                
            case 1:
            {
                GYSearchViewController *searchVC = [[GYSearchViewController alloc] init];
                [self.navigationController pushViewController:searchVC animated:YES];
            }
                break;
                
            case 2:
            {
                GYSystemMessageViewController *systemMessageVC = [[GYSystemMessageViewController alloc] initWithNibName:@"GYSystemMessageViewController" bundle:nil];
                systemMessageVC.hidesBottomBarWhenPushed = YES;
                [weakSelf.navigationController pushViewController:systemMessageVC animated:YES];

            }
                break;
                
            default:
                break;
        }
    };
    basePopoverVC.titles = @[@"首页",@"搜索",@"消息"];
    basePopoverVC.images = @[@"home_w",@"search_w",@"message_w"];
    
    self.animationDelegate = [[PopoverAnimation alloc] init];
    self.animationDelegate.popoverFrame = CGRectMake(ScreenWidth-widthScale(130, iphone6_W)-5, 50, widthScale(130, iphone6_W), basePopoverVC.titles.count*50);
    basePopoverVC.transitioningDelegate = (id)weakSelf.animationDelegate;
    
    basePopoverVC.modalPresentationStyle = UIModalPresentationCustom;
    [self presentViewController:basePopoverVC animated:YES completion:nil];

}

@end
